#ifndef	__DBAPI_PROVIDER_INCLUDE__
#define	__DBAPI_PROVIDER_INCLUDE__

class CDbRecordSet : public IDbRecordSet {
protected:
	virtual ~CDbRecordSet() { }

public:
	static CDbRecordSet* New(int nFieldCount, int nMax);

	virtual void SetFieldName(int nField, const char* pName) = 0;
	virtual void SetFieldValue(int nRow, int nField, const char* pValue) = 0;
};

class CDbClient : public IDbClient {
protected:
	CDbClient();
	virtual ~CDbClient();

public:
	virtual int ErrorCode() { return m_nErrorCode; }
	virtual const char* ErrorMsg() { return m_szErrorMsg; }

protected:
	void SetError(int nCode, const char* pMsg);

private:
	int m_nErrorCode;
	char m_szErrorMsg[1024];
};

class CDbProvider {
public:
	CDbProvider();
	virtual ~CDbProvider();

	static CDbProvider* GetProvider(const char* pName);
	static unsigned int GetProviderCount();
	static CDbProvider* GetProvider(unsigned int nIndex);

	virtual const char* GetName() = 0;
	virtual void Init() = 0;
	virtual void Final() = 0;
	virtual CDbClient* CreateClient(const char* pConnStr) = 0;
};

bool CrackConnString(const char* pConnStr, std::map<std::string, std::string>& Map);

#endif
